package demo3;

import java.util.Scanner;

public class char1 {
    public static void main(String[] args) {
        //键盘录入一个字符串，统计该字符串中的大小写字符、数字字符出现的次数
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String str = sc.next();
        int dXCount=0;
        int xXCount=0;
        int nCount=0;
        for (int i = 0; i < str.length(); i++) {
            char c =str.charAt(i);
            if(c>=97&&c<=122){    //c>='a'&&c<='z'
                xXCount++;
            } else if (c>=65&&c<=90) {
                dXCount++;
            } else if (c>=48&&c<=57) {
                nCount++;
            }
        }System.out.println("大写字符有："+xXCount+"个");
        System.out.println("小写字符有："+dXCount+"个");
        System.out.println("数字字符有："+nCount+"个");
    }
}
